<template>
  <div class="app-container">
    <el-form :inline="true" ref="formRef" :model="form" class="demo-form-inline">
      <el-form-item label="操作人账号：" prop="operName">
        <el-input
          v-model.trim="form.operName"
          placeholder="请输入"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="选择日期：" prop="_date">
        <el-date-picker
          value-format="YYYY-MM-DD HH:mm:ss"
          v-model="form._date"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        />
      </el-form-item>
      <el-form-item label="&nbsp;">
        <el-button @click="reset()">重置</el-button>
        <el-button type="primary" @click="handleQuery()">查询</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="_list">
      <el-table-column label="时间" align="center" prop="operTime" />
      <el-table-column label="操作内容" align="center" prop="title" />
      <el-table-column label="操作员账号（用户账号）" align="center" prop="operName" />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList()"
    />
  </div>
</template>

<script setup>
import { list as listApi } from '@/api/system/operlog'

const _list = ref([])
const total = ref(0)
const formRef = ref()
const form = ref({
  operName: '',
  _date: []
})
const queryParams = ref({
  pageNum: 1,
  pageSize: 10
})

/**重置数据 */
function reset() {
  formRef.value.resetFields()
  queryParams.value.pageNum = 1
  queryParams.value.pageSize = 10
  getList()
}
import { parseTime } from '@/utils/tools'
const { proxy } = getCurrentInstance()
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}
/** 获取导出列表数据 */
function getList() {
  const _param = {
    ...queryParams.value,
    title: '分账',
    businessType: 5,
    operName: form.value.operName
  }

  listApi(proxy.addDateRange(_param, form.value._date)).then((res) => {
    if (res && res.rows) {
      _list.value = res.rows.map((item) => {
        return {
          ...item,
          operTime: parseTime(item.operTime)
        }
      })
    }
    console.log(res.rows)
  })
}

getList()
</script>

<style lang="scss" scoped></style>
